#!/bin/sh

chown $_INIT_UID:$_INIT_GID $_INIT_WORKDIR
chown $_INIT_UID:$_INIT_GID ${_INIT_WORKDIR%/*}
if [ "$_INIT_USER" != "$_INIT_GROUP" -o $_INIT_UID != $_INIT_GID ]; then
	addgroup -g $_INIT_GID $_INIT_GROUP
	adduser -D -s /bin/sh -u $_INIT_UID -G $_INIT_GROUP $_INIT_USER
else
	adduser -D -s /bin/sh -u $_INIT_UID $_INIT_USER
fi
echo "$_INIT_USER:123456" | chpasswd
sed -i -e "s|/var/lib/registry|$_INIT_WORKDIR|g" /etc/docker/registry/config.yml
